package com.syc.sss.controller;

import com.syc.sss.entity.Resume;
import com.syc.sss.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class ResumeController {

    @Autowired
    private ResumeService resumeService;

    @RequestMapping("/query")
    public ModelAndView query(){
        ModelAndView mv = new ModelAndView();
        List<Resume> list = resumeService.findAll();
        mv.setViewName("index");
        mv.addObject("list",list);
        return mv;
    }

    @RequestMapping("/save")
    public String save(Resume resume){
        resumeService.save(resume);
        return "forward:query";
    }

    @RequestMapping("/delete")
    public String delete(String id){
        resumeService.delete(id);
        return "forward:query";
    }

}
